package factory;

import dao.OrderDao;
import dao.OrderDaoImpl;
import dao.UserDao;
import dao.UserDaoImpl;
import dao.RedWineDao;
import dao.RedWineDaoImpl;

/**
 * DAO层工厂类 - 实现工厂设计模式
 * 统一管理DAO实例的创建，便于后续扩展和维护
 */
public class DaoFactory {
    
    // 单例实例（可选优化）
    private static OrderDao orderDao;
    private static UserDao userDao;
    private static RedWineDao redWineDao;
    
    /**
     * 获取OrderDao实例
     * @return OrderDao实现类实例
     */
    public static OrderDao getOrderDao() {
        if (orderDao == null) {
            orderDao = new OrderDaoImpl();
        }
        return orderDao;
    }
    
    /**
     * 获取UserDao实例
     * @return UserDao实现类实例
     */
    public static UserDao getUserDao() {
        if (userDao == null) {
            userDao = new UserDaoImpl();
        }
        return userDao;
    }
    
    /**
     * 获取RedWineDao实例
     * @return RedWineDao实现类实例
     */
    public static RedWineDao getRedWineDao() {
        if (redWineDao == null) {
            redWineDao = new RedWineDaoImpl();
        }
        return redWineDao;
    }
    
    /**
     * 重置所有实例（用于测试或重新初始化）
     */
    public static void reset() {
        orderDao = null;
        userDao = null;
        redWineDao = null;
    }
}
